package vip.zhenzicheng.design_patterns.flyweight;

/**
 * @author zhenzicheng
 * @date 2022-05-26 18:08
 */
public class Client {
  public static void main(String[] args) {
    final BoxFactory cacheFactory = BoxFactory.getInstance();
    // 获取I图形对象
    AbstractBox box1 = cacheFactory.getShape("I");
    box1.display("灰色");

    // 获取L图形对象
    AbstractBox box2 = cacheFactory.getShape("L");
    box2.display("绿色");

    // 获取O图形对象
    AbstractBox box3 = cacheFactory.getShape("O");
    box3.display("灰色");

    // 获取O图形对象
    AbstractBox box4 = cacheFactory.getShape("O");
    box4.display("红色");

    System.out.println("两次获取到的O图形对象是否是同一个对象：" + (box3 == box4));
  }
}
